﻿using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Jungle.Code.DAL;
using Jungle.Code.Utils;
using Jungle.Articles;

public partial class addNews : UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Add(object sender, EventArgs e)
    {
        string ImgUrl = "/UserFiles/Images/News/def.png";

        if (fu_Img.HasFile)
        {
            string fname = "/UserFiles/Images/News/" + Session.SessionID + "_" + fu_Img.FileName;
            fu_Img.SaveAs(Server.MapPath(fname));

            ImgUrl = fname;
        }


        Article n = new Article();
        n.Title = newsTitle.Text.Trim();
        n.Description = content.Value.Trim();
        n.Img = ImgUrl;
        n.LanguageId = 1;
            HttpCookie cookie = Request.Cookies["CurrLang"];
            if (cookie != null) n.LanguageId = Convert.ToInt32(cookie["lang"]);
        n.Add();
        
        Response.Redirect("~/Admin/Modules.aspx?mod=Articles&cmd=News");

        

    }
}
